package thread.threaddemo;

/**
 * @Author: wenjingyuan
 * @Date: 2022/11/07/21:45
 * @Description:关于join的一个实例
 */
public class ThreadByJoin {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
                //张三上班
                System.out.println("张三上班");
                //张三正在上班
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //张三下班
                System.out.println("张三下班");
            });
        t.start();
        //等待线程t1结束之后，在执行后面的代码
        t.join();
        Thread thread=new Thread(()->{
            //李四上班
            System.out.println("李四上班");
            //李四正在上班
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //李四下班
            System.out.println("李四下班");
        });
        thread.start();
    }
}
